package com.block.account.enums;

import cn.hutool.core.util.ObjectUtil;
import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 操作类型枚举
 * */
@Getter
public enum ApplyStatusEnum {

    DELETE(-1, "已删除")
    ,INIT(0, "待审核")
    ,WAIT(1, "待入账")
    ,SUCCESS(2, "入账成功")
    ;

    private Integer value;
    private String name;

    public static List<Map<String, String>> getStatusMapList(){
        List<Map<String, String>> resultList = new ArrayList<>();
        for (ApplyStatusEnum actionTypeEnum : values()) {
            Map<String, String> itemMap = new HashMap<>();
            itemMap.put("key", actionTypeEnum.getName());
            itemMap.put("value", String.valueOf(actionTypeEnum.getValue()));
            resultList.add(itemMap);
        }
        return resultList;
    }

    ApplyStatusEnum(Integer value, String name){
        this.value = value;
        this.name = name;
    }

    public static String getNameByValue(Integer value){
        for (ApplyStatusEnum typeEnum : values()) {
            if (ObjectUtil.equals(typeEnum.getValue(), value)){
                return typeEnum.getName();
            }
        }
        return null;
    }

}
